package com.bootdo.hotel.dao;

import com.bootdo.hotel.domain.HotelRoomDayStatus;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 每日房态
 * @author haojiangbo
 * @email 2100272728@qq.com
 * @date 2019-10-18 14:36:55
 */
@Mapper
public interface HotelRoomDayStatusDao {

	HotelRoomDayStatus get(Long id);


	@Select("select id , hotel_id as hotelId, room_id as roomId , status , " +
			"day from me_hotel_room_day_status " +
			"where room_id = #{roomId} and day = #{day} limit 1 ")
	HotelRoomDayStatus getByRoomIdAndDay(@Param("roomId") Long roomId,@Param("day") String day);


/*	@Update(" update me_hotel_room_day_status set status = #{status} " +
			"where room_id = #{roomId} and day = #{day}")
	int updateStatusByRoomIdAndDay(@Param("roomId") Long roomId,@Param("day") String day,@Param("status") Integer status);*/


	 @Update(" update me_hotel_room_day_status set status = #{status} " +
			"where room_id = #{roomId} and day = #{day} and status <> #{tempStatus}")
	int updateStatusByRoomIdAndDay(@Param("roomId") Long roomId,@Param("day") String day,@Param("status") Integer status,@Param("tempStatus") Integer tempStatus);



	@Update(" update me_hotel_room_day_status set room_type_id = #{roomTypeId} " +
			"where room_id = #{roomId} and day >= #{day}")
	int updateRoomTypeIdByRoomIdAndDay(@Param("roomId") Long roomId,@Param("day") String day,@Param("roomTypeId") Long roomTypeId);


	@Update("select id , hotel_id as hotelId,  room_id as roomId , status , " +
			"day from me_hotel_room_day_status " +
			"where room_id = #{roomId} and day > #{startTime} and day < #{endTime} ")
	List<HotelRoomDayStatus>  getByStartTimeAndEndTime(@Param("roomId") Long roomId,@Param("startTime") String startTime,@Param("endTime") String endTime);


	@Update("select id ,hotel_id as hotelId,  room_id as roomId , status , " +
			"day from me_hotel_room_day_status " +
			"where hotel_id = #{hotelId} and day > #{startTime} and day < #{endTime} ")
	List<HotelRoomDayStatus>  getByHotelAndStartTimeAndEndTime(@Param("hotelId") Long hotelId,@Param("startTime") String startTime,@Param("endTime") String endTime);

	@Update("select id ,hotel_id as hotelId,  room_type_id as roomTypeId, room_id as roomId , status , " +
			"day from me_hotel_room_day_status " +
			"where room_type_id = #{roomTypeId} and day > #{startTime} and day < #{endTime} ")
	List<HotelRoomDayStatus>  getByHotelRoomTypeIdAndStartTimeAndEndTime(@Param("roomTypeId") Long roomTypeId,@Param("startTime") String startTime,@Param("endTime") String endTime);


	Integer getRoomStockByDate(@Param("hotelId") Long hotelId,@Param("roomTypeId") Long roomTypeId,@Param("day") String day);

	List<HotelRoomDayStatus> list(Map<String,Object> map);
	
	int count(Map<String,Object> map);
	
	int save(HotelRoomDayStatus hotelRoomDayStatus);
	
	int update(HotelRoomDayStatus hotelRoomDayStatus);
	
	int remove(Long id);
	
	int batchRemove(Long[] ids);
}
